474A - Keyboard - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

letter = input()
line = input()
keyboard = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 'z',
            'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/']
output = ""
index = 0
if letter == 'R':
    for x in line:
        index = keyboard.index(x)
        output += keyboard[index - 1]
elif letter == 'L':
    for x in line:
        index = keyboard.index(x)
        output += keyboard[index + 1]

print(output)

C++ Code:

#include <bits/stdc++.h>
#define loop(n)      for (int i=0;i<n ;i++)
#define endl     '\n'
#define ll     long long
using namespace std;

void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main()
{

    init() ;
    ll n,x;
    char type , c;
  map <char ,int > m ;
  string s ="qwertyuiopasdfghjkl;zxcvbnm,./" ;
  loop (s.length())
  {
     m[s[i]]=i ;
  }
  cin>> type ;
  if (type=='R')
    {

       while (cin>> c )
       {
           cout << s[m[c]-1] ;
       }
    }
    else 
    {
       while (cin>> c )
       {
           cout << s[m[c]+1] ;
       }  
    }




    return 0;
}


Comments

Submit
0 Comments
More Questions

Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences